<template>
  <div>
    <div class="seachDiv">全部</div>
    <el-row :gutter="20" style>
      <el-col :span="18">
        <div
          class="contentDiv"
          style=" display: grid;grid-gap: 10px;grid-template-columns: repeat(4, 1fr);"
        >
          <div
            class="content"
            v-bind:class="{ active: isActive }"
            v-for="(item,index) in list"
            :key="index"
            v-on:mouseover="!isActive"
          >
            <img v-if="item.imgURL" :src="item.imgURL" class="contentImg"/>
            <img v-if="!item.imgURL" src="https://picture-1257052444.cos.ap-beijing.myqcloud.com/beijing.png" class="contentImg"/>
            <div class="contentButtom">
              <a class="contentTitle" @click="toContent(item)">{{item.title}}</a>
            </div>
          </div>
        </div>
      </el-col>
      <el-col :span="4">
        <div class="listDiv"></div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
export default {
  name: "seachVue",
  data() {
    return {
      isActive: false,
      list: []
    };
  },
  methods: {
    toContent(item) {
      console.log(item);
      this.$router.push({
        path: "content",
        query: {
          id: item._id
        }
      });
    }
  },
  mounted() {
    const vlaue = this.$route.query.vlaue;
    this.$axios
      .get("/api/data/title/" + vlaue)
      .then(res => {
        console.log(res);
        this.list = res.data;
      })
      .catch(err => {
        console.log(err);
      });
  }
};
</script>

<style>
.content {
  min-height: 260px;
  border-radius: 5px;
  background-color: #ffffff;
   border: 1px solid #cccccc;
}
.contentImg {
  border-radius: 5px 5px 0 0;
  max-height: 230px; 
  height: 230px;
  width: 100%;
  overflow: hidden;
}
.contentImg::-webkit-scrollbar {
  /*隐藏滚轮*/
  display: none;
}
.contentButtom {
  width: 100%;
  /* margin: 0; */
  margin: 0;
  min-height: 80px;
  text-overflow: ellipsis;
}
.contentTitle {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 15px;
  font-weight: normal;
  padding: 5px;
}
.headIcon {
  width: 30px;
  height: 30px;
  margin-top: -10px;
  margin-bottom: 10px;
  border-radius: 50%;
  float: left;
  margin-right: 5px;
}
.name {
  font-size: 13px;
}
.divborder {
  margin-top: -10px;
}
a:hover {
  color: #ff0000;
}
a {
  text-decoration: none;
  color: #000;
}
.content:hover {
  border: 1px solid #e6a23c;
}
.seachDiv {
  background-color: #ffffff;
  margin: 5px 120px;
  height: 70px;
  border-radius: 5px;
  line-height: 70px;
  text-align: center;
}
.listDiv {
  width: 100%;
  min-height: 500px;
  background-color: #ffffff;
}
</style>

